<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if (!function_exists('ext_set_value')) {
	function ext_set_value($field = '', $default = '') {
		if (!isset($_GET[$field])) {
			return $default;
		}
			
		return form_prep($_GET[$field], $field);
	}
}

if (!function_exists('ext_set_select')) {
	function ext_set_select($field = '', $value = '', $default = FALSE) {
		if (!isset($_GET[$field])) {	
			if (count($_GET) === 0 AND $default == TRUE) {
				return ' selected="selected"';
			}
			return '';
		}
		
		$field = $_GET[$field];
		
		if (is_array($field)) {
			if (!in_array($value, $field)) {
				return '';
			}
		} else {
			if (($field == '' OR $value == '') OR ($field != $value)) {
				return '';
			}
		}
		
		return ' selected="selected"';
	}
}